//
//  MainViewController.m
//  ZFPlatform
//
//  Created by magus on 11-5-30.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "MainViewController.h"
#import "CPopupMenu.h"
#import "LoginViewController.h"


@implementation MainViewController

@synthesize menu;


//通过xib资源初始化视图控制器
//
+ (MainViewController*) InitFromXib
{
	self = [[MainViewController alloc] 
			initWithNibName:@"MainViewController" bundle:nil];
	return self;
}


//初始化界面
//
- (void) InitAllViews
{
	//设置导航栏标题
	[self setTitle:@"首页"];
}


//响应工具栏 -- "菜单"
//
- (IBAction) OnToolBar_Menu: (id) sender
{
	if (menu.isPopup)
	{
		[menu Hide];
	}
	else
	{
		[menu Popup];
	}
}


//响应菜单 -- "登录"
//
- (IBAction) OnMenu_Login: (id) sender
{
	if (loginViewController == nil)
		loginViewController = [LoginViewController InitFromXib];
	
	[self.navigationController pushViewController:loginViewController animated:YES];
}


//响应工具栏 -- "退出"
//
- (IBAction) OnToolBar_Exit: (id) sender
{
}


// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {	
    [super viewDidLoad];
	[self InitAllViews];
	
}

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc
{
	[loginViewController release];
	[menu release];
	
    [super dealloc];
}


@end
